﻿import clr

def move_up(p1, p2, p3):
    p1.RenderImage = p2.GetObject("char_up_loader").Properties["LoadedImage"]
    p1.Properties["velx"] = 0
    p1.Properties["vely"] = -1
    return True

def move_down(p1, p2, p3):
    p1.RenderImage = p2.GetObject("char_down_loader").Properties["LoadedImage"]
    p1.Properties["velx"] = 0
    p1.Properties["vely"] = 1
    return True

def move_right(p1, p2, p3):
    p1.RenderImage = p2.GetObject("char_right_loader").Properties["LoadedImage"]
    p1.Properties["velx"] = 1
    p1.Properties["vely"] = 0
    return True

def move_left(p1, p2, p3):
    p1.RenderImage = p2.GetObject("char_left_loader").Properties["LoadedImage"]
    p1.Properties["velx"] = -1
    p1.Properties["vely"] = 0
    return True

def moveUpdate(p1, p2, p3):
    #for Object in p2.GetObjects():
    #    if Object.Properties["collision"] == False:
    #        continue
    #    if ((p1.Position.X + (p1.Properties["velx"] * p3.ElapsedGameTime.TotalSeconds)) >= Object.Position.X and (p1.Position.X + (p1.Properties["velx"] * p3.ElapsedGameTime.TotalSeconds)) <= Object.Position.X + Object.Size.X) or ((p1.Position.X + p1.Size.X + (p1.Properties["velx"] * p3.ElapsedGameTime.TotalSeconds)) >= Object.Position.X and (p1.Position.X + p1.Size.X + (p1.Properties["velx"] * p3.ElapsedGameTime.TotalSeconds)) <= Object.Position.X + Object.Size.X):
    #        if ((p1.Position.Y + (p1.Properties["vely"] * p3.ElapsedGameTime.TotalSeconds)) >= Object.Position.Y and (p1.Position.Y + (p1.Properties["vely"] * p3.ElapsedGameTime.TotalSeconds)) <= Object.Position.Y + Object.Size.Y) or ((p1.Position.Y + p1.Size.Y + (p1.Properties["vely"] * p3.ElapsedGameTime.TotalSeconds)) >= Object.Position.Y and (p1.Position.Y + p1.Size.Y + (p1.Properties["vely"] * p3.ElapsedGameTime.TotalSeconds)) <= Object.Position.Y + Object.Size.Y):
    #            return False
    p1.Position.X += (p1.Properties["velx"])
    p1.Position.Y += (p1.Properties["vely"])
    p1.Properties["velx"] = 0
    p1.Properties["vely"] = 0
    return True